<template>
  <el-container>
    <div v-if="$route.meta.keepAlive">
    <el-header>
      <div class="a2"><h><font size="5" color="white">fancy music</font></h></div>
      <div class="a1"><el-avatar :size="35" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></el-avatar></div>
      <div class="home_input">
<!--        <el-input placeholder="请输入内容" v-model="search_text">-->
<!--          <el-button slot="append" icon="el-icon-search"></el-button>-->
<!--        </el-input>-->
        <el-select
          v-model="value"
          multiple
          filterable
          remote
          reserve-keyword
          placeholder="请输入关键词"
          :remote-method="remoteMethod"
        ></el-select>
      </div>
    </el-header>
    <el-container>
      <el-aside width="200px"><!--左部-->
        <el-row class="tac">
          <el-col :span="24">
            <el-menu
              default-active="2"
              class="el-menu-vertical-demo"
              @open="handleOpen"
              @close="handleClose"
              background-color="#545c64"
              text-color="#fff"
              active-text-color="#ffd04b">
              <el-menu-item index="1">
                <i class="el-icon-umbrella"></i>
                <span slot="title">fancy主页</span>
              </el-menu-item>
              <el-menu-item index="2" @click="goTo('/MusicList')">
                <i class="el-icon-search"></i>
                <span slot="title" >发现音乐</span>
              </el-menu-item>
              <el-menu-item index="3">
                <i class="el-icon-s-data"></i>
                <span slot="title">音乐排行</span>
              </el-menu-item>
              <el-menu-item index="4">
                <i class="el-icon-headset"></i>
                <span slot="title">播放音乐</span>
              </el-menu-item>
              <el-menu-item index="5">
                <i class="el-icon-house"></i>
                <span slot="title">我的空间</span>
              </el-menu-item>
            </el-menu>
          </el-col>
        </el-row>
      </el-aside>
      <!--<el-container>
        <el-main>Main</el-main>&lt;!&ndash;主题&ndash;&gt;
      </el-container>-->
    </el-container>
      <router-view v-if="!$route.meta.keepAlive"></router-view>
    </div>
  </el-container>
</template>

<script>
  export default {
    name: "index",
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      handleSelect(key, keyPath) {
        console.log(key, keyPath);
      },
      goTo(path) {
        this.$router.replace(path);
      },
      remoteMethod(query) {
        console.log(query)
        this.query = query;
        if (query !== '') {
          // this.loading = true;
          //使用axios去查询内容
          axios.get("http://127.0.0.1:8200/fancy-music-es/search/" + query).then(res => {
            // this.tableData = res.data.list;
            console.log(res.data.total)
            // this.total=res.data.total;
          })
        }else{
          // this.selectFoodBySid()
        }
    },

    data() {
      return{
        activeIndex: '1',
        activeIndex2: '1',
        input: '',
        search_text: ''
      }
    }
  }
</script>

<style scoped>
  .el-header{
    background-color: #545c64;
    color: #333;
    text-align: center;
    line-height: 60px;
  }

  .el-aside {
    background-color: #D3DCE6;
    color: #666666;
    text-align: center;
    line-height: 200px;
    height: 600px;
  }

  .el-main {
    color: #333;
    text-align: center;
    line-height: 160px;
    background-color: #D3DCE6;
  }
  .a1{
    line-height: 80px;
    float: right;
    width: 40px;
    height: 50px;
  }
  .home_input{
    float: right;
    width: 300px;
    line-height: 60px;
    margin-right: 150px;
  }
  .a2{
    float: left;
    margin-left: 50px;
  }

</style>
